package mebp.genetic.recombination;

import java.util.Vector;

import mebp.genetic.Individuum;

public class MultiPointCrossover implements RecombinationStrategy {

	@Override
	public Vector<Individuum> recombine(Individuum... parents) {
		Individuum i1 = parents[0];
		Individuum i2 = parents[1];
		int genomLength = i2.genom.length;

		int child1[] = new int[genomLength];
		int child2[] = new int[genomLength];
		for (int i = 0; i < genomLength; i++) {
			if (Math.random() > 0.5) {
				child1[i] = i1.genom[i];
				child2[i] = i2.genom[i];
			} else {
				child1[i] = i2.genom[i];
				child2[i] = i1.genom[i];
			}
		}
		Vector<Individuum> result = new Vector<Individuum>();
		result.add(new Individuum(i1.problem, child1));
		result.add(new Individuum(i1.problem, child2));
		return result;
	}

}
